var opinionPrice;

/**
 * 设置结果接收对象
 * @param _opinionPrice
 */
function setModel(_opinionPrice) {
    if (_opinionPrice == undefined || !(_opinionPrice instanceof com.jf.crawl.model.OpinionPrice)) {
        throw new java.lang.Exception("opinionPrice 对象为空");
    }
    log.info("opinionPrice {}", _opinionPrice)
    opinionPrice = _opinionPrice;
}

function crawler() {
    //拍拍贷
    var html = httpClient.Get("http://rise.invest.ppdai.com/#0");
    var newHtml = html.replaceAll("\\s+", "");
    var x = GetText(newHtml, "var_xaxis=\\[(.*)\\],//X轴坐标");
    var y = GetText(newHtml, "_data=\\[(.*)\\],//数据");
    var months = x.split(",");
    var prices = y.split(",");
    if (months.length == prices.length) {
        for (var i = 0; i < months.length; i++) {
            var month = GetText(months[i],"\\d+");
            var price = prices[i];
            if ("1".equals(month)) {
                opinionPrice.setOneMonth(commonUtil.string2Decimal(price));
            } else if ("2".equals(month)) {
                opinionPrice.setTwoMonth(commonUtil.string2Decimal(price));
            } else if ("3".equals(month)) {
                opinionPrice.setThreeMonth(commonUtil.string2Decimal(price));
            } else if ("6".equals(month)) {
                opinionPrice.setSixMonth(commonUtil.string2Decimal(price));
            } else if ("9".equals(month)) {
                opinionPrice.setNineMonth(commonUtil.string2Decimal(price));
            } else if ("12".equals(month)) {
                opinionPrice.setOneYear(commonUtil.string2Decimal(price));
            }
        }
    }
    return true;
}